<?php
namespace Tbf\Bundle\TbfBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('tbf');
        $rootNode
            ->children()
                ->append($this->addDatabaseNode())
            ->end()
        ->end();

        return $treeBuilder;
    }
    public function addDatabaseNode()
    {
        $treeBuilder = new TreeBuilder();
        $node = $treeBuilder->root('database');
        $node
            ->children()
                ->scalarNode('host')
                    ->defaultValue('127.0.0.1')
                    ->info('database host name')
                    ->example('127.0.0.1')
                    ->end()
                ->scalarNode('port')
                    ->defaultValue('3306')
                    ->info('database host port')
                    ->example('3306')
                    ->end()
                ->scalarNode('dbname')->end()
                ->scalarNode('username')->defaultValue('root')->end()
                ->scalarNode('password')->end()

                ->scalarNode('encode')->defaultValue('UTF8')->end()
                ->scalarNode('prefix')->defaultValue('')->end()
                ->scalarNode('type')->defaultValue('pdo_mysql')->end()

                ->end()
            ->end();

        return $node;
    }
}
